package com.file.module.mapper;

import com.file.module.entity.File;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface FileMapper {

    @Select("select * from file where is_deleted = 0 and type = 1")
    List<File> getAllImage();

    // 根据ID查询（逻辑未删除）
    @Select("select * from file where id =#{id} and is_deleted = 0")
    File getById(@Param("id") Long id);

    // 根据ID查询（包含已删除）
    @Select("select * from file where id =#{id}")
    File extractById(@Param("id") Long id);

    // 插入
    int insert(@Param("file") File file);

    // 更新
    int update(@Param("file") File file);

    // 逻辑删除
    @Update("update file set is_deleted = 1, update_time=#{time} where id = #{id} limit 1 ")
    int delete(@Param("id") Long id, @Param("time") Integer time);
}